{% extends 'base.html' %}

{% block content %}



<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>查看用户</h2>
    </div>
    <div class="col-lg-2">
    </div>
</div>

{% if request.user.is_superuser %}
    <div class="wrapper wrapper-content animated fadeIn">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins" id="all">
                    <div class="ibox-title">
                        <h5> 用户名详细信息列表</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>

                    <div class="ibox-content">
                        <form action="{% url 'getServices' %}" method="post" id="checkall">

                            <table class="table table-striped table-bordered table-hover " id="editable" name="editable">
                                <thead>
                                    <tr>
                                        <th class="text-center"> 用户名 </th>
                                        <th class="text-center"> 姓名 </th>
                                        <th class="text-center"> 电话 </th>
                                        <th class="text-center"> 邮箱 </th>
                                        <th class="text-center"> 状态 </th>
                                        <th class="text-center"> 操作 </th>
                                    </tr>
                                </thead>
                                <tbody>
                                {% for info in user_list %}
                                    <tr class="gradeX">
                                        <td class="text-center"> {{ info.username }}</td>
                                        <td class="text-center"> {{ info.first_name }} </td>
                                        <td class="text-center"> {{ info.userprofile.phone_number }} </td>
                                        <td class="text-center">{% if info.email %} {{ info.email }} {% else %} {% endif %}</td>
                                        {% if info.is_active %}
                                            <td class="text-center">有效</td>
                                            <td class="text-center">
                                                <a href="/users/user_edit/{{ info.id }}/" class="btn btn-xs btn-info">修改</a>
                                                <a href="/users/user_is_active/{{ info.id }}/" class="btn btn-xs btn-danger">禁用</a>
                                            </td>
                                        {% else %}
                                            <td class="text-center">禁用</td>
                                            <td class="text-center">
                                                <a href="/users/user_edit/{{ info.id }}/" class="btn btn-xs btn-info">修改</a>
                                                <a href="/users/user_is_active/{{ info.id }}/" class="btn btn-xs btn-success">启用</a>
                                            </td>
                                        {% endif %}
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </form>
                    </div>
                    <ul class="pager">
                        {% if user_list.has_previous %}
                            <li><a href="?page={{ user_list.previous_page_number }}">Previous</a></li>
                        {% endif %}
                            <li>Page {{ user_list.number }} of {{ user_list.paginator.num_pages }}.</li>
                        {% if user_list.has_next %}
                            <li><a href="?page={{ user_list.next_page_number }}">Next</a></li>
                        {% endif %}
                    </ul>
                </div>
            </div>
        </div>
    </div>
{% endif %}
{% endblock %}



